<?xml version="1.0" encoding="utf-8" ?>
<Batch
    xmlns="http://schemas.dbshell.com/core"
    xmlns:ds="http://schemas.dbshell.com/dataset"
    Connection="sqlserver://MultipleActiveResultSets=True;Data Source=localhost\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=Chinook"
    >
  <QueryValue VariableName="var1">
    SELECT COUNT(*) FROM MediaType
  </QueryValue>
  
  <ForEach Source="{Query 'SELECT * FROM Album'}">
    <SaveToFile Value="${AlbumId}" File="data${AlbumId}.txt" />
  </ForEach>

  <Razor Model="GetDatabase()" Template="DatabaseDoc.cshtml" File="docs.html" />
  <Razor Model="{Query 'SELECT * FROM Album'}" Template="TableData.cshtml" File="table.html" />

  <SetTableProperty Table="t1" Name="x" />
  <DatabaseProvider VariableName="s1" />
  
  <UseDatabase VariableName="s1" >
    <SetTableProperty Table="t1" Name="x" />
    <Razor Model="{Database}" />
  </UseDatabase>
  
  <Batch Connection="var://s1">
    
  </Batch>
 
  
  <ds:DataSet VariableName="ds1" Connection="TARGET_CONNECTION">
    <ds:LoadFile File="test.cdl" />
    <ds:AddRow Table="Album" Condition="AlbumId=1" Connection="SOURCE_CONNECTION" />
    <ds:LoadReference FkTable="Track" PkTable="Album" />
    <ds:LoadMissing Table="Genre" />
    <ds:LoadMissing Table="MediaType" />
  </ds:DataSet>

  <ds:WriteSql DataSet="{Eval ds1}" File="test1.sql" >
    <ds:Lookup Table="Genre" IdColumn="GenreId" ValueColumn="Name" />
  </ds:WriteSql>
  
  <ds:WriteFiles File="index.dsi">
  </ds:WriteFiles>
</Batch>
